<?php
/**
 * Created by PhpStorm.
 * User: 83697
 * Date: 2018/10/11
 * Time: 20:50
 */

namespace App\Helper;

use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;

class Utils
{

    public static function getTeaScheduleStatus($t)
    {
        if($t == -1) {
            return '-';
        } else if ($t == 0) {
       // if($t < 1) {
        return config('svs.tea_schedule.'.$t);
       } else {
        return '<a href="'.config('app.url').'/lesson?id='.$t.'">'.$t.'</a>';
       }
    }

         //console log sql
    /**
     * [sqlLog description]
     * @param  string  $sql  [sql语句]
     * @param  array   $bing [绑定参数]
     * @param  integer $time [sql执行时间]
     * @return none 
     */
    static function sqlLog($sql, $bing=[], $time=0)
    {

        include_once( app_path("Libs/ChromePhp.php") );

        foreach($bing as $v) {
            $sql = preg_replace("/\?/", $v, $sql, 1);
        } 

        $now = date("Y-m-d H:i:s", time());
        $ret = "{$now} USE:{$time} :   {$sql}";
        \ChromePhp::log( $ret );
        // \ChromePhp::warn('something went wrong!');
        logger($ret);
        return; 
    }   

}